﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace NewRen.Models.ViewModel
{
    public class vBusiness
    {
        public int ID { get; set; }

        /// <summary>
        /// 商户登录名
        /// </summary>

        public string LoginName { get; set; }

        /// <summary>
        /// 商户密码
        /// </summary>
        public string LoginPassword { get; set; }

        /// <summary>
        /// 真是姓名
        /// </summary>
        public string RealName { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string Phone { get; set; }


        /// <summary>
        /// 自我描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 城市
        /// </summary>
        public string City { get; set; }

        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }
        /// <summary>
        /// 邮件
        /// </summary>
        public string Email { get; set; }


        /// <summary>
        /// 性别
        /// </summary>
        public Sex Sex { set; get; }


        /// <summary>
        /// 积分
        /// </summary>
        public int? Integration { get; set; }

        /// <summary>
        /// 金钱
        /// </summary>
        public double Money { get; set; }


        /// <summary>
        /// 微博
        /// </summary>
        public string Weibo { get; set; }

        /// <summary>
        /// 微信
        /// </summary>
        public string WhatApp { get; set; }

        /// <summary>
        /// 商家名称
        /// </summary>
        public string BusinessName { get; set; }


        /// <summary>
        /// 上次登录时间
        /// </summary>
        public DateTime? LastLogin { get; set; }

        /// <summary>
        /// 优先级 用于排名
        /// </summary>
        public int Priority { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public byte[] Picture { get; set; }
        /// <summary>
        /// 访问量
        /// </summary>
        public int PV { get; set; }
        /// <summary>
        /// 今日访问量
        /// </summary>
        public int TodayPV { get; set; }

        /// <summary>
        ///赞
        /// </summary>
        public int Ups { get; set; }

        /// <summary>
        /// 踩
        /// </summary>
        public int Downs { get; set; }

        public List<Images> Images { get; set; }
        /// /// <summary>
        /// 增加时间
        /// </summary>
        public DateTime? AddTime { get; set; }

        /// <summary>
        /// 行业
        /// </summary>
        public string Industry { get; set; }


        /// <summary>
        /// 是否认证
        /// </summary>
        public bool IsVerified { set; get; }


        public vBusiness() { }

        public vBusiness(Business business)
        {
            DB db = new DB();
            this.ID = business.ID;
            this.BusinessName = business.BusinessName;
            this.LoginName = business.LoginName;
            this.LoginPassword = business.LoginPassword;
            this.Email = business.Email;
            this.Phone = business.Phone;
            this.Address = business.Address;
            this.AddTime = business.AddTime;
            this.Weibo = business.Weibo;
            this.WhatApp = business.WhatApp;
            this.Description = business.Description;
            this.LastLogin = business.LastLoginTime;
            this.City = business.City;
            this.Picture = business.Picture;
            this.Priority = business.Priority;
            this.Industry = business.Industry;
            this.TodayPV = business.TodayPV;
            this.PV = business.PV;
            this.Downs = business.Downs;
            this.Ups = business.Ups;
            this.Images = db.Images.Where(c => c.TID == business.ID).Where(c => c.ImageType == ImageType.Business).ToList();
            this.IsVerified = business.IsVerified;
        }
    }
}
